//
//  FeedBackViewController.swift
//  weile
//
//  Created by LKM on 16/10/25.
//  Copyright © 2016年 LKM. All rights reserved.
//

import UIKit
/**
 反馈
 */
class FeedBackViewController: BaseViewController {

    @IBOutlet weak var tv_phone: UITextField!
    @IBOutlet weak var tv_content: UITextView!
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    @IBAction func onSubmitClick(_ sender: AnyObject) {
        loadData();
    }

    func loadData(){
        if(StringHelp.isEmpty(tv_phone.text)){
            ViewHelp.showTipsView(containView: self.view, tips: "请留下您的联系方式")
            return;
        }
        if(StringHelp.isEmpty(tv_phone.text)){
            ViewHelp.showTipsView(containView: self.view, tips: "请留下您的意见")
            return;
        }
        
        
        ViewHelp.showProgressActivity(containView: self.view)
        let ts=Api.feedbacksave(preTaskSerialNumber: nil,content: tv_content.text ?? "" ,phone: tv_phone.getText() ) { (re:ResponEntity) in
            ViewHelp.hideProgressActivity(containView: self.view);
            guard re.isSuccess() else{
                ViewHelp.showTipsView(containView: self.view, tips: re.msg)//成功不显示
                return;
            }
            ViewHelp.showAlertTipsDialog(tips: "谢谢您的反馈", okBtn: "确实", okRun: { 
                self.finish(animated: true)
            })
        }
        
        taskAlls.append(ts);
    }
    
    var taskAlls = [Int]();
    deinit {
        //界面退出肯定就不登陆咯
        Api.destroyTask(taskSerialNumbers: taskAlls);
    }
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
